package com.nsapi.niceschoolapi.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.nsapi.niceschoolapi.entity.TeacherDB;
import com.nsapi.niceschoolapi.mapper.TeacherMapper;
import com.nsapi.niceschoolapi.service.TeacherService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;
import java.util.Map;

@Service("teacherService")
public class TeacherServiceImpl implements TeacherService {
    @Resource
    private TeacherMapper teacherMapper;

    @Override //录入教师信息
    public int addTeacher(TeacherDB teacherDB) {
        return teacherMapper.insert(teacherDB);
    }

    @Override //分页查询教师信息
    public List<TeacherDB> teacherList(Map<String, Object> map) {
        return teacherMapper.teacherPage(map);
    }

    @Override  //按id查询教师详细信息
    public TeacherDB getTeacher(Integer id) {
        QueryWrapper<TeacherDB> wrapper=new QueryWrapper<TeacherDB>();
        wrapper.eq("tid",id);
        return teacherMapper.selectOne(wrapper);
    }

    @Override //修改教师信息
    public int updateTeacher(TeacherDB teacherDB) {
        return teacherMapper.updateById(teacherDB);
    }
}
